package com.dream.keigezhushou.Activity.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.dream.keigezhushou.R;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 个人主页RecyclerView的适配器
 */

public class HomepageAdapter extends RecyclerView.Adapter<HomepageAdapter.MyViewHolder> {


    private Context mContext;
    private LayoutInflater inflater;
    private MyViewHolder mHolder;

    //    private String[] styleId = {"单曲", "合唱"};
    private int c = 16;
    private int a = 8;

    public HomepageAdapter(Context context) {

        this.mContext = context;
    }

    @Override
    public int getItemCount() {
        return c;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        inflater = LayoutInflater.from(mContext);
        View view = inflater.inflate(R.layout.layout_grid_item, parent, false);

        mHolder = new MyViewHolder(view);
        return mHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {

//        holder.tvStyle.setText(styleId[position]);
        //创建作品的集合
//        ArrayList<String> arrayList = new ArrayList<String>();
//
//        //判断集合是否为空
//        if (arrayList.isEmpty()){
//
//            holder.itemGrid.setVisibility(View.GONE);
//        }else {
//
//            holder.itemGrid.setVisibility(View.VISIBLE);
//            handlerGrid(holder);
//        }
//        holder.itemGrid.setVisibility(View.VISIBLE);
//        handlerGrid(holder);
    }

//    private void handlerGrid(MyViewHolder mHolder) {
//
//        GridAdapter adapter = new GridAdapter(mContext);
//        mHolder.itemGrid.setAdapter(adapter);
//    }


    class MyViewHolder extends RecyclerView.ViewHolder {

        //        TextView tvStyle;
//        RecyclerView itemGrid;
        ImageView ivPost;
        TextView tvSong;
        TextView tvNum;

        public MyViewHolder(View itemView) {
            super(itemView);

            AutoUtils.autoSize(itemView);
//            tvStyle = (TextView) itemView.findViewById(R.id.tv_style);
//            itemGrid = (RecyclerView) itemView.findViewById(R.id.rv_list2);
            ivPost = (ImageView) itemView.findViewById(R.id.iv_post);
            tvSong = (TextView) itemView.findViewById(R.id.tv_song_name);
            tvNum = (TextView) itemView.findViewById(R.id.tv_number);
        }
    }

//    class GridAdapter extends RecyclerView.Adapter<GridAdapter.ViewHolder> {
//
//        private Context context;
//
//        public GridAdapter(Context context) {
//
//            this.context = context;
//        }
//
//        @Override
//        public int getItemCount() {
//            return 0;
//        }
//
//        @Override
//        public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//
//            View view = inflater.inflate(R.layout.layout_grid_item, parent, false);
//
//            ViewHolder viewHolder = new ViewHolder(view);
//
//            return viewHolder;
//        }
//
//        @Override
//        public void onBindViewHolder(ViewHolder holder, int position) {
//
//
//        }
//
//        class ViewHolder extends RecyclerView.ViewHolder {
//
//            ImageView ivPost;
//            TextView tvSong;
//            TextView tvNum;
//
//            public ViewHolder(View itemView) {
//                super(itemView);
//
//                ivPost = (ImageView)itemView.findViewById(R.id.iv_post);
//                tvSong = (TextView)itemView.findViewById(R.id.tv_song_name);
//                tvNum = (TextView)itemView.findViewById(R.id.tv_number);
//
//            }
//
//        }
//    }
}
